/**
 * @Author: lusx
 * @Date:   07-03-2019 11:50:38
 * @Project: Govern督办
 * @Last modified by:   lusx
 * @Last modified time: 20-03-2019 02:13:07
 */
import React from "react";
import { Icon } from "weaver-mobile";
import { Toast, Tools } from "weaver-mobile";
import { toJS } from "mobx";
const getLabel = Tools.getLabel;

//将后端数组转为react数组
const GetBtnEle = (data, index) => {
  const btnEle = data[index].map(obj => ({
    icon: <Icon type={obj.icon} />,
    title: obj.label,
    key: obj.key
  }));
  return btnEle;
};
//点击按钮触发方法
const Toasts = {
  "2": () => {
    Toast.hide();
    Toast.success(getLabel("25436,84565", "关注成功"));
  },
  "3": () => {
    Toast.hide();
    Toast.success(`${getLabel("16248", "提交成功！")}`);
  },
  "4": () => {
    Toast.hide();
    Toast.success(`${getLabel("16248", "提交成功！")}`);
  },
  "5": () => {
    Toast.hide();
    Toast.success(`${getLabel("16248", "提交成功！")}`);
  },
  "6": () => {
    Toast.hide();
    Toast.success(`${getLabel("16634,84565", "确认成功！")}`);
  },
  "7": () => {
    Toast.hide();
    Toast.success(`${getLabel("383313", "废弃成功")}`);
  },
  "8": () => {
    Toast.hide();
    Toast.success(`${getLabel("16248", "提交成功！")}`);
  },
  "9": () => {
    Toast.hide();
    Toast.success(`${getLabel("501355", "已签收任务")}`);
  },
  "11": () => {
    Toast.hide();
    Toast.success(`${getLabel("119,15242", "共享成功")}`);
  },
  "12": () => {
    // Toast.hide();
    Toast.loading('Loading...',0)
    Toast.success(getLabel("385762", "已取消关注"));
  },
  "13": () => {
    Toast.hide();
    Toast.success(`${getLabel("387965,84565", "下发成功！")}`);
  },
  "17": () => {
    Toast.hide();
    Toast.offline('请前往pc端进行操作');
  },
  "18": () => {
    Toast.hide();
    Toast.offline('请前往pc端进行操作');
  },
  "1003": () => {
    Toast.hide();
    Toast.success(`${getLabel("83472", "删除成功")}`);
  },
  "1004": () => {
    Toast.hide();
    Toast.success(`${getLabel("508139", "重启成功")}`);
  }
};
const Tooltips = {
  "6": [
    `${getLabel("15172", "系统提示")}`,
    `${getLabel("501181", "完结当前任务会同时完结所有所属子任务，确认完结？")}`
  ],
  "7": [
    `${getLabel("15172", "系统提示")}`,
    `${getLabel("501179", "废弃当前任务会同时废弃所有所属子任务，确认废弃？")}`
  ],
  "17": [
    `${getLabel("15172", "系统提示")}`,
    `${getLabel("501175", "确认要申请延期吗")}`
  ],
  "18": [
    `${getLabel("15172", "系统提示")}`,
    `${getLabel("501174", "确认要申请办结吗")}`
  ],
  "13": [
    `${getLabel("15172", "系统提示")}`,
    `${getLabel("501177", "是否要下发当前任务？")}`
  ],
  "1003": [
    `${getLabel("131329", "信息确认")}`,
    `${getLabel("506748", "确认要删除该任务吗？")}`,
    `${getLabel("506497", "确认要删除该任务及下级任务吗？")}`
  ],
  "1004": [
    `${getLabel("131329", "信息确认")}`,
    `${getLabel("508192", "确认要重新开启此任务吗？")}`,
    `${getLabel("508140", "确认要重新开启此任务及上级任务吗？")}`
  ]
};
//设置动作面板行按钮个数
const SetRowBtnNum = params => {
  let data = [];
  if (params.isRight === true) {
    if (params.sheetBtns.length >= 5) {
      data.push(params.sheetBtns.slice(0, 5));
      data.push(params.sheetBtns.slice(5));
    } else {
      data.push(toJS(params.sheetBtns));
    }
  } else {
    null;
  }
  return data;
};
export default {
  GetBtnEle,
  Toasts,
  SetRowBtnNum,
  Tooltips
};
